package com.javasm.sys.tree;

import com.javasm.sys.SysDepart;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class DeptTreeUtil {

    public static List<SysDepart> buildTree(Collection<SysDepart> list, String pid) {
        List<SysDepart> r = new ArrayList<>();
        for (SysDepart dept : list) {
            if(pid.equals(dept.getPid())){
                String id = dept.getDepartId();

//                尚马基金 子部门数据
                List<SysDepart> childs = buildTree(list, id);
                if(childs!=null && childs.size()>0){
                    dept.setDepartList(childs);

                }
                r.add(dept);
            }
        }
        return r;
    }
}
